package com.asset.dispoal.menu.service.commom;

import com.asset.dispoal.menu.domain.db.entity.GbMenuDo;
import com.asset.dispoal.menu.domain.db.mapper.GbMenuMapper;
import com.asset.dispoal.menu.dto.response.GbMenuResponse;
import com.asset.dispoal.menu.service.converter.MenuConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommandNoParam;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.List;

/**
 * @author qr
 * @date 2022/2/28$
 */
@Component
public class QueryMenuCommand implements BaseCommandNoParam<Result> {


    @Autowired
    GbMenuMapper gbMenuMapper;

    @Override
    public Result<List<GbMenuResponse>> execute() {
        List<GbMenuDo> gbMenuDos = gbMenuMapper.queryAll();
        List<GbMenuResponse> gbMenuResponses = MenuConverter.INSTANCE.doToRes(gbMenuDos);
        return MenuList.getListResult(gbMenuResponses);
    }
}



